package xinxin.com.AbstractFactoryPatternWithSimpleFactory.DataBase;

import xinxin.com.AbstractFactoryPatternWithSimpleFactory.Sql.IDepartment;
import xinxin.com.AbstractFactoryPatternWithSimpleFactory.Sql.IUser;

/**
 * @author ：Shixinin
 * @date ：Created in 2019/3/25 21:14
 */
public class DataBase {
    private static final String ASSEMBLY_NAME = "xinxin.com.AbstractFactoryPatternWithSimpleFactory.Sql.SqlDetail";
    private static final String DATABASE = "Access";
    //static private final String DATABASE = "Sqlserver";

    public static IUser createUser() {
        String className = ASSEMBLY_NAME + "." + DATABASE + "User";
        IUser iUser = null;
        try {
            iUser = (IUser) Class.forName(className).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return iUser;
    }

    public static IDepartment createDepartment() {
        String className = ASSEMBLY_NAME + "." + DATABASE + "Department";
        IDepartment iDepartment = null;
        try {
            iDepartment = (IDepartment) Class.forName(className).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return iDepartment;
    }
}
